package com.lwm.annotationandreflection.ref;

import com.lwm.entity.Employee;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Map;

/**
 * @author liweimin
 * @date 2020/9/25 14:53
 * @description 反射操作泛型
 */
public class ref10 {
    public void test01(Map<String, Employee> map){}

    public static void main(String[] args) throws NoSuchMethodException {
        Method test01 = ref10.class.getMethod("test01", Map.class);
        Type[] genericParameterTypes = test01.getGenericParameterTypes();
        for (Type genericParameterType : genericParameterTypes) {
            System.out.println("#"+genericParameterType);
            if(genericParameterType instanceof ParameterizedType){
                Type[] actualTypeArguments = ((ParameterizedType) genericParameterType).getActualTypeArguments();
                for (Type actualTypeArgument : actualTypeArguments) {
                    System.out.println(actualTypeArgument);
                }
            }
        }

    }
}
